import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-search',
  templateUrl: './search.component.html',
  styleUrls: ['./search.component.less']
})
export class SearchComponent implements OnInit {

  public keyword: string
  public list: Array<any> = []

  constructor() { }

  ngOnInit(): void {
  }

  doSearch() {
    this.keyword = this.keyword.trim()
    if (this.list.indexOf(this.keyword) == -1 && this.keyword) {
      this.list.unshift(this.keyword)
    }
    this.keyword = ''
  }

  deleteItem(key) {
    this.list.splice(key, 1)
  }

}
